package cn.hengzhu.main_manager.service.impl;


import cn.hengzhu.main_manager.repository.dao.ManageCaseTypePriceMapper;
import cn.hengzhu.main_manager.repository.domain.ManageCaseTypePrice;
import cn.hengzhu.main_manager.repository.domain.ManageCaseTypePriceExample;
import cn.hengzhu.main_manager.service.ManageCaseTypePriceService;
import cn.hengzhu.main_manager.utils.AmountUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author 谭芸
 * @create 2021-04-01 10:55
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class ManageCaseTypePriceServiceImpl implements ManageCaseTypePriceService {

    @Autowired
    private ManageCaseTypePriceMapper mcpMapper;

    /**
     * 获取柜子收费类型信息
     * @param typeId
     */
    @Override
    public List<ManageCaseTypePrice> getChargeType(Integer typeId) throws Exception {
//        ManageCaseType manageCaseType = manageCaseTypeMapper.selectByPrimaryKey(typeId);
        ManageCaseTypePriceExample example = new ManageCaseTypePriceExample();
        example.createCriteria().andCaseTypeIdEqualTo(typeId);
        List<ManageCaseTypePrice> manageCaseTypePrices = mcpMapper.selectByExample(example);
        for (ManageCaseTypePrice manageCaseTypePrice : manageCaseTypePrices) {
            String thePrice = manageCaseTypePrice.getThePrice();
            manageCaseTypePrice.setThePrice(AmountUtils.changeF2Y(thePrice));

        }
        return manageCaseTypePrices;
    }



}
